package ${package.Controller};

import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import org.springframework.web.bind.annotation.*;
import cn.com.surker.spring.RestResultDto;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import javax.annotation.Resource;
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
*
* @author ${author}
* @since ${date}
*/

@RestController
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>")
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Resource
    private ${table.serviceName}  serviceImpl;

    /**
     *  分页查询列表
     **/
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public RestResultDto findAll(${entity} dto, Integer pageIndex, Integer limit){
        /**分页对象**/
        Page<${entity}> page = new Page<>(pageIndex, limit);

        return serviceImpl.findAllByPage(dto, page);
    }

    /**
     *  新增数据
     * @param dto
     **/
    @RequestMapping(value = "/save", method = RequestMethod.PUT)
    @ResponseBody
    public RestResultDto save(${entity} dto){

        return serviceImpl.saveInit(dto);
    }

    /**
     * 修改数据
     * @param dto
     * @return
     */
    @RequestMapping(value = "/update/{id}", method = RequestMethod.PUT)
    @ResponseBody
    public RestResultDto update(@PathVariable Long id, ${entity} dto) {

        return serviceImpl.update(dto);
    }

    /**
     * 删除数据
     * @param id 数据主键
     * @param status 逻辑删除状态
     * @return
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.PUT)
    @ResponseBody
    public RestResultDto update(@PathVariable Long id, Integer status) {

        return serviceImpl.delete(id, status);
    }


}



